package flink_p2_sql

import org.apache.flink.api.common.typeinfo.Types
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.table.api.{EnvironmentSettings, Table}
import org.apache.flink.table.api.scala.StreamTableEnvironment
import org.apache.flink.table.sources.CsvTableSource

object tableApi02_tableApi_CsvTableSource {


  /**
   * @param args
   */
  def main(args: Array[String]): Unit = {



    val streamEnv: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    val tableEnv: StreamTableEnvironment = StreamTableEnvironment.create(streamEnv)


    val tableSource = new CsvTableSource(
      "data/data.csv",
      Array[String]("id", "name", "age"),
      Array(Types.INT, Types.STRING, Types.INT)
    )

    tableEnv.registerTableSource("t_user", tableSource)

    val t_user: Table = tableEnv.scan("t_user")



    t_user.printSchema()



  }
}
